from django.db import models

class User(models.Model):
    username = models.CharField(max_length=20, unique=True, db_column='用户名')
    password = models.CharField(max_length=128, db_column='密码')
    mobile = models.CharField(max_length=11, null=True, db_column='手机号')
    isDelete = models.BooleanField(default=False, db_column='状态')
    class Meta:
        db_table = '用户表'

class Category(models.Model):
    categoryName = models.CharField(max_length=20, unique=True, db_column='分类名')
    class Meta:
        db_table = '分类表'

class Brand(models.Model):
    brandName = models.CharField(max_length=20, unique=True, db_column='品牌名')
    imgName = models.CharField(max_length=100, db_column='品牌logo')
    superior = models.ForeignKey(to=Category, related_name='SuperCategory', on_delete=models.CASCADE)
    class Meta:
        db_table = '品牌表'

class Product(models.Model):
    proName = models.CharField(max_length=20, db_column='商品名称')
    proBrand = models.ForeignKey(to=Brand, on_delete=models.CASCADE, related_name='ProductBrand')
    proDesc = models.TextField(db_column='商品描述')
    num = models.IntegerField(db_column='商品库存')
    size = models.CharField(max_length=20, db_column='商品尺寸')
    price = models.IntegerField(db_column='商品价格')
    oldPrice = models.IntegerField(db_column='商品原价')
    statu = models.IntegerField(default=1, db_column='商品状态')
    class Meta:
        db_table = '商品表'